dnl Process this file with autoconf to produce a working configure script.
AC_INIT(Makefile.in)
AC_CONFIG_HEADER(include/tweak.h)
AC_LN_S
AC_PROG_CC
AC_ISC_POSIX
echo checking for DYNIX/ptx 
FSP_PROGRAM_GREP(yes,
[#if defined(_SEQUENT_)
  yes
#endif
], SEQUENT=1,)
if test -n "$SEQUENT"; then
EX_LIBS="-lsocket -linet -lnsl -lseq"
PARALLEL_MAKE='\&'
CC='cc'
GCC=
echo You"'"re on Sequent.. Using cc and parallel make
fi
echo checking for SunOS 5.1
FSP_PROGRAM_GREP(yes,
[#if defined(SVR4) && defined(SPARC)
  yes
#endif
], SUNOS51=1,)
if test -n "$SUNOS51"; then
EX_LIBS="-lsockect -lnsl"
fi
AC_SUBST(EX_LIBS)
AC_SUBST(PARALLEL_MAKE)
AC_AIX
echo checking for DGUX
FSP_PROGRAM_GREP(yes,
[#if defined(DGUX)
  yes
#endif], DGUX=1,)
AC_PROG_INSTALL
AC_PROG_RANLIB
AC_DIR_HEADER
echo checking for ansi-style prototypes
AC_TEST_PROGRAM([main(int argc,char **argv){exit(0);}],
                AC_DEFINE(HAVE_ANSI_PROTO),,)
if test -n "$GCC"; then
AC_DEFINE(HAVE_ANSI_PROTO)
fi
AC_STDC_HEADERS
AC_HAVE_HEADERS(string.h memory.h strings.h)
AC_LONG_FILE_NAMES
echo checking for word sizes
AC_TEST_PROGRAM([ main(){ exit(sizeof(unsigned)!=2); }], AC_DEFINE(SIZE_INT_2))
AC_TEST_PROGRAM([ main(){ exit(sizeof(unsigned)!=4); }], AC_DEFINE(SIZE_INT_4))
AC_TEST_PROGRAM([ main(){ exit(sizeof(short)!=2); }], AC_DEFINE(SIZE_SRT_2))
AC_TEST_PROGRAM([ main(){ exit(sizeof(long)!=4); }], AC_DEFINE(SIZE_LNG_4))
AC_UNISTD_H
FSP_MODE_T
FSP_PID_T
FSP_SIZE_T
FSP_UID_T
FSP_NLINK_T
AC_FUNC_CHECK(bsearch , , AC_DEFINE(bsearch, ansi_bsearch))
AC_FUNC_CHECK(random , , AC_DEFINE(NEED_RANDOM))
AC_FUNC_CHECK(strdup, , AC_DEFINE(NEED_STRDUP))
AC_FUNC_CHECK(bcopy, , AC_DEFINE(NEED_BCOPY))
AC_FUNC_CHECK(flock, AC_DEFINE(HAVE_FLOCK), )
AC_FUNC_CHECK(lockf, AC_DEFINE(HAVE_LOCKF), )
echo checking for shmget
LOCKPATH="conftestlock"
AC_TEST_PROGRAM([
#include <sys/types.h>
#include <fcntl.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#define LOCKPATH "$LOCKPATH"

main() {
  key_t ky;
  int   sh, rv, fd;

  fd = open(LOCKPATH, O_RDWR | O_CREAT, 0666);
  if (fd == -1) exit(1);
  rv = 0;
  ky = ftok(LOCKPATH, 2001);
  if (ky == (key_t) -1) rv = 1;
  else {
    struct shmid_ds foo;
    sh = shmget(ky, 1, IPC_CREAT | 0666);
    if (sh == -1) rv = 1;
    else shmctl(sh, IPC_RMID, &foo);
  }
  close(fd);
  exit(rv); }], AC_DEFINE(HAVE_SHMEM))
rm -f $LOCKPATH conftest.c
AC_COMPILE_CHECK(d_ino, [#ifdef DIRENT
#include <dirent.h>
#else
#ifdef SYSDIR
#include <sys/dir.h>
#else
#ifdef SYSNDIR
#include <sys/ndir.h>
#endif
#endif
#endif], [
#ifdef DIRENT
struct dirent *dp;
#else
struct direct *dp;
#endif
int a ; a=dp->d_ino;], AC_DEFINE(HAVE_D_INO), )
AC_COMPILE_CHECK(d_fileno, [#ifdef DIRENT
#include <dirent.h>
#else
#ifdef SYSDIR
#include <sys/dir.h>
#else
#ifdef SYSNDIR
#include <sys/ndir.h>
#endif
#endif
#endif], [
#ifdef DIRENT
struct dirent *dp;
#else
struct direct *dp;
#endif
int a ; a=dp->d_fileno;], AC_DEFINE(HAVE_D_FILENO), )
if test -z "$DGUX"; then
AC_COMPILE_CHECK(union wait,[#include <sys/types.h>
#include <sys/wait.h>
], [union wait u ; ], AC_DEFINE(HAVE_UNION_WAIT),)
fi
AC_COMPILE_CHECK(WEXITSTATUS, [#ifdef HAVE_UNISTD_H
#ifndef __hpux
#include <unistd.h>
#endif
#endif
#include <sys/types.h>
#include <sys/wait.h>], [
#if defined(HAVE_UNION_WAIT) && !defined(__hpux)
union wait foo;
#else
int foo;
#endif
WEXITSTATUS(foo);], AC_DEFINE(HAVE_WEXITSTATUS), )
AC_COMPILE_CHECK(S_ISREG, [#include <sys/types.h>
#include <sys/stat.h>],
		 [struct stat sb; return S_ISREG(sb.st_mode);],
		 AC_DEFINE(HAVE_S_ISREG), )
AC_COMPILE_CHECK(S_ISDIR, [#include <sys/types.h>
#include <sys/stat.h>],
		 [struct stat sb; return S_ISDIR(sb.st_mode);],
		 AC_DEFINE(HAVE_S_ISDIR), )
AC_HEADER_CHECK(tzfile.h, [TZFILE_H=1
AC_DEFINE(HAVE_TZFILE_H)],
		[AC_DEFINE(USE_SECSPERDAY, (long)60*60*24)
		 AC_DEFINE(USE_DAYSPERNYEAR, 365)])
if test -n "$TZFILE_H"; then
AC_COMPILE_CHECK(SECSPERDAY, [#include <tzfile.h>], [long b = SECSPERDAY;],
		 AC_DEFINE(HAVE_SECSPERDAY),
		 [AC_COMPILE_CHECK(SECS_PER_DAY, [#include <tzfile.h>],
				   [long b = SECS_PER_DAY;],
				   AC_DEFINE(USE_SECSPERDAY, SECS_PER_DAY),
				   AC_DEFINE(USE_SECSPERDAY, (long)60*60*24))])
AC_COMPILE_CHECK(DAYSPERNYEAR, [#include <tzfile.h>], [int b = DAYSPERNYEAR;],
		 AC_DEFINE(HAVE_DAYSPERNYEAR),
		 [AC_COMPILE_CHECK(DAYS_PER_NYEAR, [#include <tzfile.h>],
				   [int b = DAYS_PER_NYEAR;],
				   AC_DEFINE(USE_DAYSPERNYEAR, DAYS_PER_NYEAR),
				   AC_DEFINE(USE_DAYSPERNYEAR, 365))])
fi
echo checking for string.h declaring some functions incorrectly
echo "$DEFS
#include <sys/types.h>
#include <string.h>
" > conftest.c
$CC conftest.c -o conftest $LIBS > conftest.out 2>&1
if grep "conflicting types for built-in function" conftest.out >/dev/null; then AC_DEFINE(STRING_H_BOGUS)
fi
rm -f conftest*
AC_VPRINTF
if test -z "$GCC"; then
  AC_CONST
fi
AC_OUTPUT(Makefile)
